<template>
  <div class="root">
    <van-nav-bar
      :fixed="true"
      title="我的出租"
      right-text="去发布"
      left-arrow
      @click-left="$router.go(-1)"
      @click-right="$router.push('/rent/add')"
    />
    <HouseItem v-for="(item,index) in list" :item="item" :key="index"/>
  </div>
</template>

<script>
import HouseItem from "../components/HouseItem";
import { request } from "../utils/index.js";
export default {
  components: { HouseItem },
  data() {
    return {
      list: []
    };
  },
  async created() {
    this.$toast.loading({
      message: "加载中",
      duration: 0
    });
    const res = await request.get("/user/houses");
    this.list = res.data.body;
    this.$toast.clear();
  }
};
</script>
<style lang="less" scoped>
.root {
  padding-top: 46px;
}
</style>

